#ifndef _AVL_H
#define	_AVL_H

#include "main.h"

#define LEFT 0
#define RIGHT 1
#define NEITHER -1

typedef float value_t;
typedef int direction;

typedef struct node_s {
   value_t        value;
   struct node_s *next[2];
   unsigned int nChildren;
   int            longer:2;
   unsigned int repeated;
} *node;

typedef struct elements_s {
    unsigned int nUniq;
    unsigned int nSum;
} elements;

void avlRebalancePath(node path, value_t target);
node avlRotateTwo(node *path_top, direction dir);
node avlRotateThree(node *path_top, direction dir, direction third);
void avlRebalance(node *path_top, value_t target);
int avlInsert(node *treep, value_t target, unsigned int setRepeated);
void avlConcate(node *tree1, node tree2, elements *el);
void avlShow(node);

#endif

